import spock.lang.Specification
/**
 * Created at 2017/10/13 19:30
 * @author gongweixin
 */
class NumberExample extends Specification {
    def "test String to Number"() {
        expect:
        (1 / 2).class == BigDecimal.class
        (2 / 1).class == BigDecimal.class
        (1 * 2).class == Integer.class
        (1 * 2.0).class == BigDecimal.class
    }

    def "test / 0 "() {
        expect:
        Double.NaN == 0D / 0D
        Double.POSITIVE_INFINITY == 1D / 0D
        Double.NEGATIVE_INFINITY == -1D / 0D
    }

    def "NaN to BigDecimal"() {
        expect:
        (BigDecimal)Double.NaN
    }
}
